import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** PI 排班套餐明细信息 */
export interface ConfigureComboDetail {
  id: number // 主键
  piConfigureComboId?: number // 排班套餐id
  piShiftId?: number // 班次id
  user?: string // 人员岗位
  houseId?: string // 房屋id
  piBomId?: string // 档案id
  beginDate?: string // 开始时间
  endDate?: string // 结束时间
}

/** PI 排班套餐信息 */
export interface ConfigureCombo {
  id: number // 主键
  title?: string // 标题
  bz: string // 备注
  configurecombodetails?: ConfigureComboDetail[]
}

// PI 排班套餐 API
export const ConfigureComboApi = {
  // 查询PI 排班套餐分页
  getConfigureComboPage: async (params: any) => {
    return await request.get({ url: `/pi/configure-combo/page`, params })
  },

  // 获得排班套餐简列表
  getConfigureComboSimpleList: async () => {
    return await request.get({ url: `/pi/configure-combo/simple-list` })
  },

  // 查询PI 排班套餐详情
  getConfigureCombo: async (id: number) => {
    return await request.get({ url: `/pi/configure-combo/get?id=` + id })
  },

  // 新增PI 排班套餐
  createConfigureCombo: async (data: ConfigureCombo) => {
    return await request.post({ url: `/pi/configure-combo/create`, data })
  },

  // 修改PI 排班套餐
  updateConfigureCombo: async (data: ConfigureCombo) => {
    return await request.put({ url: `/pi/configure-combo/update`, data })
  },

  // 删除PI 排班套餐
  deleteConfigureCombo: async (id: number) => {
    return await request.delete({ url: `/pi/configure-combo/delete?id=` + id })
  },

  /** 批量删除PI 排班套餐 */
  deleteConfigureComboList: async (ids: number[]) => {
    return await request.delete({ url: `/pi/configure-combo/delete-list?ids=${ids.join(',')}` })
  },

  // 导出PI 排班套餐 Excel
  exportConfigureCombo: async (params) => {
    return await request.download({ url: `/pi/configure-combo/export-excel`, params })
  },

  // ==================== 子表（PI 排班套餐明细） ====================

  // 获得PI 排班套餐明细列表
  getConfigureComboDetailListByPiConfigureComboId: async (piConfigureComboId) => {
    return await request.get({
      url:
        `/pi/configure-combo/configure-combo-detail/list-by-pi-configure-combo-id?piConfigureComboId=` +
        piConfigureComboId
    })
  }
}
